package org.sociald.wave;

import com.google.wave.api.*;

/**
 * Created by IntelliJ IDEA.
 * User: jackie
 * Date: Dec 18, 2009
 * Time: 4:05:35 PM
 * To change this template use File | Settings | File Templates.
 */
public class SocialDServlet extends AbstractRobotServlet {
    @Override
    public void processEvents(RobotMessageBundle bundle) {
        Wavelet wavelet = bundle.getWavelet();

        if (bundle.wasSelfAdded()) {
            Blip blip = wavelet.appendBlip();
            TextView textView = blip.getDocument();
            textView.append("I'm alive!");
        }

        for (Event e : bundle.getEvents()) {
            if (e.getType() == EventType.DOCUMENT_CHANGED) {
                Blip blip = wavelet.appendBlip();
                TextView textView = blip.getDocument();
                textView.append("Hi, everybody!");
            }
        }
    }
}
